"""
状态码：成功1000，失败1001，不确定1003
"""
import json

from django.http import HttpResponse, JsonResponse


class MenuResponseMessage:
    @staticmethod
    def success(data):
        result = {"status": 1000, "data": data}
        return HttpResponse(json.dumps(result), content_type='application/json')

    @staticmethod
    def fail(data):
        result = {"status": 1001, "data": data}
        return HttpResponse(json.dumps(result), content_type='application/json')

    @staticmethod
    def other(data):
        result = {"status": 1002, "data": data}
        return HttpResponse(json.dumps(result), content_type='application/json')


# 商品响应类
class GoodsResponseMessage:
    @staticmethod
    def success(data):
        result = {"status": 2000, "data": data}
        return HttpResponse(json.dumps(result), content_type='application/json')

    @staticmethod
    def fail(data):
        result = {"status": 2001, "data": data}
        return HttpResponse(json.dumps(result), content_type='application/json')

    @staticmethod
    def other(data):
        result = {"status": 2002, "data": data}
        return HttpResponse(json.dumps(result), content_type='application/json')


# 购物车响应类
class CartResponse:
    @staticmethod
    def success(data):
        result = {"status": 3000, "data": data}
        return JsonResponse(result, safe=False)

    @staticmethod
    def fail(data):
        result = {"status": 3001, "data": data}
        return JsonResponse(result, safe=False)

    @staticmethod
    def other(data):
        result = {"status": 3002, "data": data}
        return JsonResponse(result, safe=False)


# 用户响应类
class UserResponse:
    @staticmethod
    def success(data):
        result = {"status": 4000, "data": data}
        return JsonResponse(result, safe=False)

    @staticmethod
    def fail(data):
        result = {"status": 4001, "data": data}
        return JsonResponse(result, safe=False)

    @staticmethod
    def other(data):
        result = {"status": 4002, "data": data}
        return JsonResponse(result, safe=False)
